home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-10-30 | 4.0 KB | 121 lines | [TEXT/MACA] |
- \ Read IMIV for a description of what this might be used for..care must
- \ be taken not to move memory, rely on unlocked handles, etc.
- \ Remember to remove tasks prior to exiting the application.
-
- hex
- create Tinstall ( ptr -- result) popA0 " InsTime" asmcall pushd0 next,
- create Tremove ( ptr -- result) popA0 " rmvTime" asmcall pushd0 next,
- create Tprime ( len ptr -- result) popD0 popA0 " primeTime" asmcall pushd0 next,
- create geta5a3 ( -- a5 a3) 2f0d w, 2f0b w, next,
-
- 0 value TstartLen
-
- \ necessary for Time Manager calls
- \ TSTART - Converts Pascal stack format to our Forth stack format.
- \ N.B. - VERY IMPORTANT!!! - This word will never be
- \ directly executed. Instead the code will be CMOVE'd
- \ into place during the execution of TPROC and executed by
- \ the routine active via JSR.
-
- Create Tstart <[ \ a1 points to record
- 204e w, \ movea.l a6,a0 \ store return stack ptr
- 2C4F w, \ movea.l a7,a6 \ save parm stack
- 9DFC w, 1b58 , \ suba.l #7000,a6 \ allow stack to have 7000 bytes
- 2D08 w, \ move.l a0,-(a6) \ save old return stack ptr here
- 2D1F w, \ move.l (a7)+,-(a6) \ save return address here
- 48E63F1C , \ movem.l d2-d7/a3-a5,-(a6) \ save these registers, including a5
- 2a690012 , \ move.l 18(a1),a5 \ get myA5
- 26690016 , \ move.l 22(a1),a3 \ get myA3
- 2A0E w, \ move.l a6,d5 \ let ret stack have only 300
- 0485 w, 12c , \ subi.l #300,d5 \ and give method stack the rest
- 49FA0006 , \ lea 6(pc),a4 \ load a4 with ptr to routine
- next,
-
- \ TEXIT - This code is equally tricky as the above TSTART. This
- \ restores the old A6 register and then jumps back to the
- \ return location from which the word was called. This
- \ code word will be invoked through the colon code, but
- \ colon-code will never see it again.
- Create T;s <[
- 4CDE38FC , \ movem.l (a6)+,d2-d7/a3-a5 \ restore a3 and a5 especially
- 205E w, \ movea.l (a6)+,a0
- 2C5E w, \ movea.l (a6)+,a6
- 4ED0 w, \ jmp (a0)
-
- Decimal
- ' T;s nfa ' Tstart - -> TstartLen
-
- \ build a word that looks like a Pascal procedure at its PFA
- : :TPROC
- ?exec create \ build hdr, cfa
- ' tstart here tstartLen allot tstartLen cMove
- cflush \ flush caches on appropriate machines
- ]> ; \ enter compilation state
-
- : ;TPROC Compile T;s [Compile] <[ ; Immediate
-
-
- :CLASS time <super object
-
- var qlink
- int qtype
- var tmAddr
- var tmCount \ don't believe IM..this needs to be 4 bytes
- var tmDelay
- var myA5
- var myA3
-
- \ once installed, and then removed, you may reInstall using this method
- :M reInstall: ( --) abs: self Tinstall abort" can't start" ;M
-
- \ Use this method as the first thing...It loads up the record with values
- :M install: ( cfaProc -- ) geta5a3 put: myA3 put: myA5
- +base >body put: tmAddr reInstall: self ;M
-
- \ To remove the task from the queue
- :M remove: ( --) abs: self Tremove abort" can't remove" ;M
-
- :M setDelay: ( n --) put: tmDelay ;M
-
- :M getDelay: ( -- n) get: tmDelay ;M
-
- \ start the task...it doesn't repeat, but must be restarted for continuous operation
- :M go: abs: self get: tmDelay Tprime abort" can't start" ;M
-
- :M start: go: self ;M
-
- :M classinit: 1 put: qtype ;M
-
- ;CLASS
-
-
- \ procedure is to install a TprocWord, set the delay when the TprocWord should execute,
- \ and when you want to start timing, say go:
- \ When you're completely done, just remove:
-
- \ schedule: might change to time: or something. The classname might also change.
-
- \ rect suz
- \ 100 100 200 200 put: suz
- \
- \ time painter time clearer
- \ :tproc paintit pushPort set: fwind paint: suz popPort go: clearer ;tproc
- \ :tproc clearit pushPort set: fwind set: fwind clear: suz draw: suz popPort go: painter ;tproc
- \ 3000 setdelay: painter
- \ 1000 setdelay: clearer
- \
- \ 'c paintit install: painter
- \ 'c clearit install: clearer
- \ go: painter
- \
- \ : stopthem remove: painter remove: clearer ;
-
- \ or another way
- \ 0 value PaintOrClear
- \ :tproc paintit pushPort set: fwind PaintOrClear IF paint: suz ELSE clear: suz draw: suz THEN
- \ PaintOrClear 1 xor -> PaintOrClear popPort go: painter ;tproc
- \ 'c paintit install: painter
- \ go: painter
-
-
-